//
//  ICRedPacketButton.m
//  ICome
//
//  Created by 席鹏飞 on 2016/11/25.
//  Copyright © 2016年 iCom. All rights reserved.
//

#import "ICRedPacketButton.h"
#import "ICMessageModel.h"
#import "ICHeaderFile.h"

@interface ICRedPacketButton ()

@property (nonatomic, strong) UIImage *image;
@property (nonatomic, strong) UIImageView *imageV;
@property (nonatomic, strong) UILabel *messageLabel;
@property (nonatomic, strong) UILabel *descLabel;

@end

@implementation ICRedPacketButton

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
    }
    return self;
}

- (void)setMessageModel:(ICMessageModel *)messageModel
{
    _messageModel = messageModel;
    ICMessage *message = messageModel.message;
    
    self.messageLabel.text = message.lnk;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat leftMargin = 12;
    CGFloat rightMargin = 8;
    
    self.image = [UIImage imageNamedFromiComeSDKBundle:@"icon_my_redpacket_message"];
    self.imageV.left = leftMargin;
    self.imageV.top = 12;
    self.imageV.width = self.image.size.width;
    self.imageV.height = self.image.size.height;
    
    self.messageLabel.left = leftMargin + rightMargin + self.imageV.width;
    self.messageLabel.top = self.imageV.top;
    self.messageLabel.width = self.width - leftMargin - rightMargin * 2 - self.imageV.width;
    self.messageLabel.height = self.imageV.height / 2;
    
    self.descLabel.left = self.messageLabel.left;
    self.descLabel.top = self.messageLabel.bottom;
    self.descLabel.width = self.messageLabel.width;
    self.descLabel.height = self.messageLabel.height;
}


#pragma mark - Getter

- (UIImageView *)imageV
{
    if (!_imageV) {
        _imageV = [[UIImageView alloc] initWithImage:self.image];
        [self addSubview:_imageV];
    }
    return _imageV;
}

- (UILabel *)messageLabel
{
    if (!_messageLabel) {
        _messageLabel = [[UILabel alloc] init];
        _messageLabel.font = [UIFont systemFontOfSize:15.0];
        _messageLabel.textColor = ICRGB(0xfcfde2);
        [self addSubview:_messageLabel];
    }
    return _messageLabel;
}

- (UILabel *)descLabel
{
    if (!_descLabel) {
        _descLabel = [[UILabel alloc] init];
        _descLabel.font = [UIFont systemFontOfSize:12.0];
        _descLabel.textColor = ICRGB(0xfcfde2);
        _descLabel.text = @"领取红包";
        [self addSubview:_descLabel];
    }
    return _descLabel;
}

@end
